package com.itheima.stock.controller;

import com.github.pagehelper.PageHelper;
import com.itheima.stock.domain.*;
import com.itheima.stock.pojo.StockBusiness;
import com.itheima.stock.service.StockService;
import com.itheima.stock.vo.res.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import javax.servlet.http.HttpServletResponse;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/quot")
public class StockController {
    @Autowired
    private StockService stockService;


    @GetMapping("/stock/business/all")
    public List<StockBusiness> getAllBusiness(){
        return stockService.getAllStockBusiness();
    }

    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> getInnerMarketInfos(){
        return stockService.getInnerMarketInfos();

    }
    @GetMapping("/sector/all")
    public R<List<StockBlockDomain>> getStockBlockInfos(){
        return stockService.getStockBlockInfos();

    }
    @GetMapping("stock/increase")
    public R<List<StockUpdownDomain>> getStockUpdownInfos(){
        return stockService.getStockUpdownInfos();

    }

    @GetMapping("external/index")
    public R<List<StockOuterMarketIndexInfoDomain>> getStockOuterMarketIndexInfos(){
        return stockService.getStockOuterMarketIndexInfos();

    }

    @GetMapping("/stock/all")
    public R<PageResult<StockUpdownDomain>> getStockUpdownInfosByPages(Integer page,Integer pageSize
    ){
        return stockService.getStockUpdownInfosByPages(page,pageSize);

    }

    @GetMapping("/stock/updown/count")
    public R<Map> getUpdownCount(){
        return stockService.getUpdownCount();

    }

    @GetMapping("/stock/export")
    public void print(HttpServletResponse response,Integer page,Integer pageSize){
         stockService.print(response,page,pageSize);
    }

    /**
     * 统计国内A股大盘T日和T-1日成交量对比功能（成交量为沪市和深市成交量之和）
     *
     */

    @GetMapping("/stock/tradevol")
    public R<Map> getTodayPreDayInfos(){
        return stockService.getTodayPreDayInfos();
    }


    /**
     *查询个股的分时行情数据，也就是统计指定股票T日每分钟的交易数据；
     */
    @GetMapping("/stock/screen/time-sharing")
    public R<List<Stock4MinuteDomain>> getStock4MinuteDomain(Integer code){
       return stockService.getStock4MinuteDomain(code);
    }


    /**
     * 统计当前时间下（精确到分钟），股票在各个涨幅区间的数量
     */
    @GetMapping("/stock/updown")
    public R<Map> getRangeCountByMinutes(){
        return stockService.getRangeCountByMinutes();
    }

    @GetMapping("/stock/screen/dkline")
    public R<List<Stock4EvrDayDomain>> getStock4EvrDayDomain(String code){
        return stockService.getStock4EvrDayDomain(code);
    }

    /**
     * 模糊查询
     */
    @GetMapping("/stock/search")
    public R<List<Map>> getFuzzyQueryStockCode(String searchStr){
        return stockService.getFuzzyQueryStockCode(searchStr);


    }

    /**
     * 股票板块描述
     * @param code
     * @return
     */
    @GetMapping("/stock/describe")
    public R<Map> getStockDescribe(String code){
        return stockService.getStockDescribe(code);
    }

    /**
     * 个股分时行情
     * @param code
     * @return
     */
    @GetMapping("/stock/screen/second/detail")
    public R<StockDetailBySecondDomain> getStockDetailBySecond(String code){
        return stockService.getStockDetailBySecond(code);
    }



}
